\name{fish.age}
\alias{fish.age}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{ Prepare a age at length data table }
\description{
 Use a Age at length matrix to produce an object of type \code{fish.age}
}
\usage{
fish.age(data, ncol = c(1, 2, 3, 4, 5))
}
\arguments{
  \item{data}{ A data matrix with year, zone, sex, age and length }
  \item{ncol}{ A vector with the position of columns year, zone, sex,
    age and sex }
}
\details{
  In fish biology the most common data recorded is weigth and length,
  obtain the age of the fish is not easy and hard structures are used
  (g. Otolitos).
  This function use a data matrix and generate an object to be used in
  the construction of a age length key.

  \code{fish.age} Sort the information of sex, length and age for
  each year and zone. It generate an object that contain the data and a
  summary  table.
}
\value{ An object of \code{\link[base]{class}} \code{"fish.age"}, it is
  a list with:
      \length item{agelength }{Data table with the next columns
	\item{year }{Year of data colection, these must be the first column (1)}
	\item{zone }{Column identifing the origen zone of the organism, this must be the second column (2)}
	\item{sex }{The sex of the organism, this must be the third column (3)}
	\item{age }{Age recorded for the organism, this must be the forth column (4)}
	\item{length }{Length recorded of the organism, these must be the fifth column (5)}
      }
      \item{TableYearSex}{Frequency table of fishes for each year and sex}
      \item{TableYearZone}{Frequency table of fishes for each year and zone}
      }
 }
\author{Jorge Cornejo-Donoso}
\note{This must be tested, please use it carefully}
\seealso{This is like \code{\link{fish.length}}}
\examples{
 ## The function is currently defined as
 \dontrun{
  library(ialk}
	year <- rep(2008, 50)
	zone <- c(rep(1,15),rep(2,25),rep(3,10))
	sex <- rbinom(50,1,.5)
	age <- abs(round(rnorm(50,14,5),0))
	length <- vector(mode = "logical", length = 50)
	for (i in 1:length(age))
		{
		length[i] <- rnorm(1, (age[i] - 1.17)/2.81, 0.71)
		}
	matrix.age <- cbind(year, zone, sex, age, length)
	  age <- fish.age(matrix.age,ncol=c(1,2,3,4,5))
  plot(age$age,age$length)
  }

\keyword{misc}
